package cn.linlane.dao.sys;

import cn.linlane.dao.BaseDao;
import cn.linlane.entity.sys.SysUser;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SysUserDao extends BaseDao<SysUser,Integer> {

    SysUser findByAccount(String account);

    boolean existsByAccount(String account);

    /**
     * 根据用户查询
     *
     * @param account
     * @return
     */
    List<SysUser> findAllByAccount(String account);

    @Query("select sysUser from SysUser sysUser " +
            "where (?1 is null or sysUser.storeCode = ?1) " +
            "and ( sysUser.account like %?2% or sysUser.username like %?2% ) ")
    Page<SysUser> fetchAllBystoreCode(String storeCode, String searchKey, Pageable pageable);

}
